home *** CD-ROM | disk | FTP | other *** search
- Path: bmecg.bme.ohio-state.edu!xiaoyi
- From: xiaoyi@bmecg.bme.ohio-state.edu (Xiaoyi Wu)
- Newsgroups: comp.lang.c
- Subject: qsort help
- Date: 3 Jan 1996 00:31:03 GMT
- Organization: Biomedical Engineering OSU
- Distribution: world
- Message-ID: <4ccio7$7c0@charm.magnus.acs.ohio-state.edu>
- Reply-To: xiaoyi@bmecg.bme.ohio-state.edu (Xiaoyi Wu)
- NNTP-Posting-Host: bmecg.bme.ohio-state.edu
- Keywords: qsort
-
- Hi, I am having some problems with the qsort routine.
-
-
- int (*compar)(int *a, int *b)
- {
- if (*a < *b) return -1;
- else if (*a == *b) return 0;
- else return 1;
- }
-
- int return_moved_contour(int ix, int iy)
- {
- int i, ac, count=0;
- int y_coord[10]; /* stores y coordinates whose x == ix */
-
- for (ac=0; ac<areaindex; ac++)
- {
- for (i=0; i<index[ac]; i++)
- {
- if (xpos[ac][i] == ix) y_coord[count++] = ypos[ac][i];
- }
- if (count == 0) continue; /* not in this contour */
- else {
- qsort(y_coord, count, sizeof(int), compar);
- i = 0;
- while (i<count/2) {
- if ((y_coord[i] <= iy) && (y_coord[i+1] >= iy))
- return ac;
- else i+=2;
- }
- }
- }
- return -1; /* cursor not within a contour, no response will be generated */
- }
-
- When I tried to compile, an error was generated:
- Error: try.c, line 791: compar must have function type
-
- I doublechecked the man page of qsort but still can't figure out what's
- wrong.
-
- Could someone give me a hand here?
-
- Thanks.
-
- Xiaoyi
-
- /=======================================================================\
- | Xiaoyi Wu || If you can't convince them, confuse them. |
- | 614-421-0934 (h) || xiaoyi@mozart.bme.ohio-state.edu |
- | 614-292-1555 (o) || http://chopin.bme.ohio-state.edu/~xiaoyi/hi.html |
- \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/
-